import type { PersistedStateOptions, StorageLike } from "pinia-plugin-persistedstate";

/**
 * @description pinia持久化配置
 * @param {string} key 持久化唯一标识
 * @param {StorageLike} persistType 持久化的类型
 * @param {string[]} paths 持久化项
 * @returns {PersistedStateOptions}
 */
export const piniaPersistConfig = (
  key: string,
  persistType: StorageLike = localStorage,
  paths?: string[]
): PersistedStateOptions => {
  const persist: PersistedStateOptions = {
    key,
    storage: persistType,
    paths
  };
  return persist;
};
